<template>
	<view class="">
		<u-form :model="form" ref="uForm">
			<template v-if="act!='view'">
				<h2>处理详情</h2>
				<u-form-item label="图片" label-width="labelWidth" required>
					<u-upload :action="action" ref="doUpload" :max-count="4" :custom-btn="true" :deletable="false">
					</u-upload>
				</u-form-item>
				<u-form-item label="视频" label-width="labelWidth" required v-if="form.do_video">
					<div class="upload-main">
						<video v-if="form.do_video" :src="form.do_video" controls></video>
					</div>
				</u-form-item>
			</template>
			<h2>事件详情</h2>
			<u-form-item label="隐患地点" label-width="labelWidth" required>
				<template>
					{{form.position}}
				</template>
			</u-form-item>

			<u-form-item label="隐患类型" label-width="labelWidth" required>
				<template>
					{{form.danger_cate}}
				</template>

			</u-form-item>
			<u-form-item label="隐患负责人" label-width="labelWidth" required>
				<template>
					{{form.charge_user_id}}
				</template>
			</u-form-item>
			<u-form-item label="隐患描述" label-width="labelWidth" required>
				<template>
					{{form.danger_detail}}
				</template>
			</u-form-item>
			<u-form-item label="视频" label-width="labelWidth" required v-if="form.resources_video">
				<div class="upload-main">

					<video v-if="form.resources_video" :src="form.resources_video" controls></video>
				</div>
			</u-form-item>
			<u-form-item label="图片" label-width="labelWidth" required>

				<u-upload :action="action" ref="uUpload" :max-count="4" :custom-btn="true" :deletable="false">

				</u-upload>
			</u-form-item>

			<template v-if="type!='edit'">
				<h2>隐患流水</h2>
				<div class="time-line-box">
					<u-time-line>

						<u-time-line-item v-for="(item,index) in dangerflow" :key="index">
							<!-- 此处没有自定义左边的内容，会默认显示一个点 -->
							<template v-slot:content>
								<view>
									<view class="u-order-desc">{{item.flow_msg}}</view>
									<view class="u-order-time">{{item.create_time}}</view>
								</view>
							</template>
						</u-time-line-item>
					</u-time-line>
				</div>
			</template>


		</u-form>
	</view>
</template>

<script>
	import {
		getCateList,
		upDanger,
		getDetail
	} from "@/api/hidden";
	let base_url = 'https://safe.81game.top'
	export default {
		data() {
			return {
				// base_url: 'https://safe.81game.top',
				action: base_url + '/api/file/upload_img.html',

				labelWidth: 150,
				form: {
					user_id: uni.getStorageSync('userInfo').id,
					org_id: uni.getStorageSync('userInfo').org_id,
					user_name: uni.getStorageSync('userInfo').nickname,
					position: '',
					danger_detail: '',
					danger_cate: 1,
					charge_user_id: '',
					resources: [],
					resources_video: '',
					danger_status: 0,
				},
				danger_id: 0,
				isProcess: false,
				charge_user: '',
				cate_list: [],
				danger_cate_name: '',
				cateShow: false,
				typeShow: false,
				type: 'view',
				imgLists: [],
				showUploadList: false,
				dangerflow: [],
			}
		},
		props: {
			// 字符串
			aaa: {
				type: String
			},
			// 布尔型
			bbb: {
				type: Boolean
			},
			// 数值
			eId: {
				type: [Number],
				default: 0
			},
			// 对象类型
			ddd: {
				type: Object
			},
			act: {
				type: [String],
				default: 'view'
			}
		},
		mounted() {
			// console.log(3335)
			this.getDetail()
		},
		methods: {
			getDetail() {
				getDetail({
					user_id: uni.getStorageSync('userInfo').id,
					org_id: uni.getStorageSync('userInfo').org_id,
					danger_id: this.eId
				}).then(res => {
					console.log(777, res)
					this.form = res.data.data.dangerinfo
					// this.imgLists = res.data.data.dangerinfo.up_imgs
					// this.imgLists = this.$refs.uUpload.lists;
					this.dangerflow = res.data.data.dangerflow
					let temp = [],
						temp2 = []
					res.data.data.dangerinfo.up_imgs.forEach((item, index) => {
						temp.push({
							url: item.res_url
						})
					})
					this.$refs.uUpload.lists = temp
					res.data.data.dangerinfo.do_imgs.forEach((item, index) => {
						temp2.push({
							url: item.res_url
						})
					})
					this.$refs.doUpload.lists = temp2
					this.form.resources_video = res.data.data.dangerinfo.up_video
					console.log(1, this.form.resources_video)
					this.form.do_video = res.data.data.dangerinfo.do_video
				})
			},

		}
	}
</script>

<style lang="scss" scoped>
	// .main-body {
	// 	padding: 20rpx 40rpx;
	// }
	@import '../hidden.scss'
</style>
